package com.code516.service.impl;

import com.code516.dao.CommentDao;
import com.code516.entity.CommentEntity;
import com.code516.service.CommentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


@Service
public class CommentServiceImpl implements CommentService {

	@Resource
	private CommentDao commentDao;
	
	
	public List<CommentEntity> findAllComment() {
		List<CommentEntity> commentEntitys = null;
		try {
			commentEntitys = commentDao.findAllComment();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return commentEntitys;
	}

	public List<CommentEntity> findAllCommentByWorkId(String workId) {
		List<CommentEntity> commentEntitys = null;
		try {
			commentEntitys = commentDao.findAllCommentByWorkId(Integer.parseInt(workId));
		} catch (Exception e) {
			e.printStackTrace();
		}
		return commentEntitys;
	}

	public int saveComment(CommentEntity commentEntity) {
		try {
			commentDao.saveComment(commentEntity);
		} catch (Exception e) {
			e.printStackTrace();
			return 0;
		}
		return 1;
	}

	
}
